<template>
  <div class="control">
    <div v-for="(item, index) in titles" :key="item.id" class="controlitem" 
    :class="{active:index===currentindex}"
    @click="getitem(index)">
      <span>{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    titles: {
      type: Array
    }
  },
  data(){
    return {
      currentindex:0
    }
  },
  methods:{
    getitem(index){
      this.currentindex=index
      this.$emit('tabbarclick',index)
    }
  }
}
</script>

<style scoped>
.control {
  display: flex;
  text-align: center;
  height: 44px;
  line-height: 44px;
  font-size: 15px;
}
.control .controlitem {
  flex: 1;
}
.active {
  color: pink;
 
}
.active span{
   border-bottom: pink solid 2px;
}
</style>
